package com.youhp.spire.xls.myDemo.Formatting;
import com.spire.xls.*;
import java.awt.*;
/**
 * 
* @ClassName: SetBorder 
* @Description: 边框设置
* @author youhp
* @date 2020年7月15日 下午2:12:22
 */
public class SetBorder {

    public static void main(String[] args) {
        //Create a workbook
        Workbook workbook = new Workbook();

        //Load the document from disk
        workbook.loadFromFile("data/SetBorder.xlsx");

        //Get the first worksheet
        Worksheet sheet = workbook.getWorksheets().get(0);

        //Get the cell range where you want to apply border style
        CellRange cr = sheet.getCellRange(sheet.getFirstRow(), sheet.getFirstColumn(), sheet.getLastRow(), sheet.getLastColumn());

        //Apply border style
        cr.getBorders().setLineStyle(LineStyleType.Double);
        //删除单元格内部的双边线
        cr.getBorders().getByBordersLineType(BordersLineType.DiagonalDown).setLineStyle(LineStyleType.None);
        cr.getBorders().getByBordersLineType(BordersLineType.DiagonalUp).setLineStyle(LineStyleType.None);
        cr.getBorders().setColor(Color.BLUE);

        //Save the document
        workbook.saveToFile("output/SetBorder.xlsx", ExcelVersion.Version2010);
    }
}
